/*
 * TMap Designer - A Thematic Map design software
 * Copyright (C) 2006 World Health Organization
 * http://www.who.int
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
package who.tmap.toolkit.shape;

import java.awt.*;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

/**
 * MapShape interface
 * 
 * @author stl
 *
 */
public interface MapShape {
	
	void setId( String id );
	String getId();
	
	/**
	 * Returns the shape type?
	 * @return the shape type
	 */
	int getType();
	
	/**
	 * Set the shape type
	 * @param type
	 */
	void setType( int type );
	
	int getEditMode();
	void setEditMode( int editMode );
	
	String getLayer();
	void setLayer( String layer );

	/**
	 * Is the shape selected
	 * @return
	 */
	boolean isSelected();
	
	/**
	 * Select the shape
	 * @param sel
	 */
	void select( boolean sel );
	
	Color getColor();
	void setColor( Color color );
	
	Color getFillColor();
	void setFillColor( Color color );

	/**
	 * Draw the shape
	 * @param g
	 */
	void draw( Graphics g );
	void fill( Graphics g );
	void fill( Graphics g, Color color );	
	
	/**
	 * Does the shape contains the specified point?
	 * @param p
	 * @return
	 */
	boolean contains( Point2D p );
	
	/**
	 * Is the shape contained in a rectangle?
	 * @param r
	 * @return
	 */
	boolean isInside( Rectangle2D r );
	
	/**
	 * Return the rectangular bounds of the shape
	 * @return
	 */
	Rectangle2D getBounds();
	
	/**
	 * Get the selection handle index at Point p
	 * @param p
	 * @return
	 */
	int getHandleIndexAt( Point2D p );
	
	/**
	 * Get the selected handle index
	 * @return
	 */
	int getSelectedHandleIndex();
	
	/**
	 * Select a handle
	 * @param idx
	 */
	void setSelectedHandleIndex( int idx );
	
	/**
	 * Shape(s) has been selected and the user is dragging a handler
	 * @param idx
	 * @param p
	 */
	void updateShape( int handlerIdx, Point2D p );
	
	/**
	 * Shape(s) has been selected and the user is moving it
	 * @param p
	 */
	void moveShape( Point2D anchor, Point2D movingAnchor );
	
	/**
	 * Some shapes need to overpass zoom
	 * @param zoomFactor
	 */
	void setZoomFactor( double zoomFactor );
	double getZoomFactor();
	
	/**
	 * Some shapes need to overpass map factor
	 * @param mapFactor
	 */	
	void setMapFactor( double mapFactor );
	double getMapFactor();
}
